package models

import "gorm.io/gorm"

type Cart struct {
	gorm.Model
	UserId     int
	GoodsId    int
	Num        int
	GoodsName  string
	GoodsPrice float64
}

func (c *Cart) AddCart() error {
	return DB.Create(&c).Error
}

func (c *Cart) IsExistCart() error {
	return DB.Where("id=?", c.ID).Limit(1).Find(&c).Error
}

func (c *Cart) UpdateNum() error {
	return DB.Update("num", c.Num).Error
}
